home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: MegaDisc / MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip / MegaDisc 38 (1994-02)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf / Programming / Disabling_OS / TakeSystem.s / TakeSystem.s
Text File  |  1994-02-09  |  4KB  |  116 lines

  1. *******************************************************************
  2. * Short example of disabling of operating system for games, etc.  *
  3. * Disables system, changes the background colours a bit and then  *
  4. * enables system.                          *    
  5. * Uses system disabling method recommended by Toby Simpson in the *
  6. * Amiga Answers column in Amiga Shopper Issue 18, October 1992.   *
  7. * Uses VPOS wait loop described by Jolyon Ralph in the Machine    *
  8. * Code column in Amiga Computing 1990.                  *    
  9. * Written by James Margitich, 20th of January 1993.               *
  10. *******************************************************************
  11.  
  12. SysBase equ 4
  13. OPENLIB equ -552
  14. CLOSELIB equ -414
  15. Forbid equ -132
  16. Permit equ -138
  17.  
  18. Exit equ -144
  19.  
  20. LoadView equ -222
  21. WaitTOF equ -270
  22.  
  23. ActiView equ 34
  24.  
  25. VPOSR equ $dff004
  26. COLOUR0 equ $dff180
  27.  
  28.     move.l  SysBase,a6              ;Put exec base address in a6
  29.     lea     doslib_name,a1        ;Put pointer to name of dos in a1
  30.     moveq   #0,d0                   ;Any version will do
  31.     jsr     OPENLIB(a6)             ;Open dos library
  32.     move.l  d0,DOSBase              ;Save base address
  33.  
  34.     lea     gfxlib_name,a1          ;put pointer to name of gfx in a1
  35.     moveq   #0,d0                   ;Any version will do
  36.     jsr     OPENLIB(a6)             ;Open graphics library
  37.     move.l  d0,GfxBase              ;Save base address
  38.     cmp.l   #0,GfxBase              ;Was zero returned?
  39.     beq     Error_No_Gfx            ;If so, call error routine
  40.  
  41.     jsr    Forbid(a6)        ;Disable multitasking
  42.  
  43.     move.l  GfxBase,a6              ;Put gfx base address in a6
  44.     move.l  ActiView(a6),a1         ;Save pointer to system copper list
  45.         move.l  a1,SysView
  46.     
  47.     move.l  #0,a1                   ;Put NULL in a1
  48.     jsr     LoadView(a6)            ;Disable system copper list
  49.     jsr     WaitTOF(a6)             ;Wait for two vertical blanks
  50.     jsr     WaitTOF(a6)             ;To give system time to stop
  51. ;Here be the body of the program. Feel free to delete this, replace it
  52. ;with your own code and rename the file accordingly.
  53.     move.l    #0,d0            ;Set loop counter to zero
  54.     move.l    #0,d1            ;Set colour counter to zero
  55.     move.w    #$3,d2            ;Set colour to $003
  56. loop
  57.     move.w    d2,COLOUR0        ;Set background colour
  58.     move.l    VPOSR,d3        ;get beam position
  59.     and.l    #%11111111100000000,d3    ;Only want vertical component
  60.     lsr.l    #8,d3            ;Move it to lower byte
  61.     cmp.w    #305,d3            ;Are we at the bottom of the screen?
  62.     bne.s    loop            ;If not, loop back now
  63.     cmp.l    #250,d0            ;Is loop counter at 250 (50vbi)?
  64.     bne    .samecolour
  65.     cmp.l    #6,d1            ;Is colour counter 6?
  66.     beq     .allfinished        ;If so, finish up.
  67.     add.w    #$002,d2        ;Increase colour no. by $002
  68.     move.l    #0,d0            ;reset loop counter
  69.     add.l    #1,d1            ;Increment colour counter    
  70.     bra.s    loop            ;Just reset counter, remember?
  71. .samecolour
  72.     add.l    #1,d0            ;Increment loop counter
  73. .fullframe
  74.     move.l    VPOSR,d3        ;get beam position
  75.     and.l    #%11111111100000000,d3    ;Only want vertical component
  76.     lsr.l    #8,d3            ;Move it to lower byte
  77.     cmp.w    #305,d3            ;Are we on next frame?
  78.     bge    .fullframe           ;If not, wait until we are
  79.     bra.s    loop            ;Loop back
  80. .allfinished    
  81. ;Here be where the main program ends.
  82.     move.l  GfxBase,a6              ;Put gfx base address in a6
  83.     move.l  SysView,a1              ;Put pointer to system view in a1
  84.     jsr     LoadView(a6)            ;Enable sytem
  85.     jsr     WaitTOF(a6)             ;Wait for two vertical blanks
  86.     jsr     WaitTOF(a6)             ;To let system get started
  87.  
  88.     move.l  SysBase,a6              ;Get ready to close libraries
  89.     jsr    Permit(a6)        ;Enable multitasking
  90.  
  91.     move.l  GfxBase,a1              ;Put gfx base address in a1
  92.     jsr     CLOSELIB(a6)            ;Close gfx library
  93.  
  94.     move.l  DOSBase,a1              ;Put dos base address in a1
  95.     jsr     CLOSELIB(a6)        ;close dos library
  96.  
  97.     rts         
  98.  
  99. Error_No_Gfx:
  100.         move.l  DOSBase,a6      ;Get ready to use dos library
  101.         move.l  #20,d1          ;returnCode set to 20
  102.         jsr    Exit(a6)        ;Exit the program
  103.  
  104. doslib_name:
  105.         dc.b  "dos.library",0
  106.  
  107. gfxlib_name:
  108.         dc.b  "graphics.library",0
  109.  
  110.     even
  111. DOSBase  dc.l 0
  112. GfxBase  dc.l 0    
  113.  
  114. SysView:
  115.       ds.l  1    
  116.